#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
__int128 read(){
    __int128 res = 0;
    char c = getchar();
    while(!isdigit(c)){
        c = getchar();
    }
    while(isdigit(c)){
        res = res*10 + c - '0';
        c = getchar();
    }
    return res;
}
const __int128 one = 1;
int m = 0;
const int PRE = 2e7+10;
int minP[PRE];
int phi[PRE];
int phi1[PRE];
void init(){
    phi[1] = 1;
    phi1[1] = 1;
    vector<int> p;
    for(int i = 2;i<=m;i++){
        if(!minP[i]){
            p.push_back(i);
            phi[i] = i - 1;
            minP[i] = i;
        }
        for(int j = 0;1ll*p[j] * i <= m && minP[i] != p[j];j++){
            minP[i* p[j]] = p[j];
            phi[i * p[j]] = phi[i] * phi[p[j]];
        }
        if(1ll*minP[i]*i <= m){
            minP[i * minP[i]] = minP[i];
            phi[i * minP[i]] = phi[i] * minP[i];
        }
    }
    for(int i = 1;i<=m;i++){
        phi1[i] = (phi1[i - 1] + 1ll*phi[i]*i%MOD)%MOD;
        phi[i] = (phi[i - 1] + phi[i])%MOD;
    }
}
unordered_map<long long,int> pmp;
const int INV2 = (MOD + 1)/2,INV3 = (MOD + 1)/3;
int qs_phi(long long p){
    if(p <= m){
        return phi[p]; 
    }
    if(pmp.count(p)){
        return pmp[p];
    }
    int res = p%MOD*(p%MOD + 1)%MOD*INV2%MOD;
    long long r = 0;
    for(long long l = 2;l <= p;l = r + 1){
        r = min(p/(p/l),p);
        res = (res + MOD - (r - l + 1)%MOD*qs_phi(p/l)%MOD)%MOD;
    }
    pmp[p] = res;
    return res;
}
unordered_map<long long,int> pi1mp;
int qs_phi1(long long p){
    if(p <= m){
        return phi1[p];
    }
    if(pi1mp.count(p)){
        return pi1mp[p];
    }
    int ts = p%MOD;
    int res = 1ll*ts*(ts + 1)%MOD*(2*ts%MOD + 1)%MOD*INV2%MOD*INV3%MOD;
    long long r = 0;
    for(long long l = 2;l <= p;l = r + 1){
        r = min(p / (p / l),p);
        res = (res + MOD - 1ll*(r - l + 1)%MOD*((l + r)%MOD)%MOD*INV2%MOD*qs_phi1(p/l)%MOD)%MOD;
    }
    pi1mp[p] = res;
    return res;
}
signed main(){
    __int128 n = read();
    long long p = 0;
    {
        long long l = 1,r = 1e11;
        while(l <= r){
            long long mid = (l + r)/2;
            if(one*(mid + 1)*(mid + 1)*(mid + 1) - 1 <= n){
                p = mid;
                l = mid + 1;
            }else{
                r = mid - 1;
            }
        }
    }
    cerr<<p<<'\n';
    m = powl(p*4.0,2.0l/3);
    cerr<<m<<'\n';
    init();
    long long r = 0;
    int res = 0;
    for(long long l = 1;l <= p;l = r + 1){
        r = min(p/(p/l),p);
        int ts = (p/l)%MOD;
        res = (res + 1ll*(qs_phi(r) - qs_phi(l - 1) + MOD)%MOD*ts%MOD)%MOD;
        res = (res + 1ll*(qs_phi(r) - qs_phi(l - 1) + MOD)%MOD*(ts + 1)%MOD*ts%MOD*INV2%MOD*3%MOD)%MOD;
        res = (res + 1ll*(qs_phi1(r) - qs_phi1(l - 1) + MOD)%MOD*(2*ts%MOD + 1)%MOD*(ts + 1)%MOD*ts%MOD*INV2%MOD)%MOD;
    }
    if(one*(p + 1)*(p + 1)*(p + 1)-1 < n){
        long long p1 = p + 1;
        for(long long l = 1;l*l <= p1;l++){
            if(p1 % l == 0){
                if(l * l == p1){
                    int c1 = ((n/l)%MOD - ((one*p1*p1*p1 - 1)/l)%MOD + MOD)%MOD;
                    res = (res + 1ll*(qs_phi(l) - qs_phi(l - 1) + MOD)%MOD*c1%MOD)%MOD;
                }else{
                    int c1 = ((n/l)%MOD - ((one*p1*p1*p1 - 1)/l)%MOD + MOD)%MOD;
                    res = (res + 1ll*(qs_phi(l) - qs_phi(l - 1) + MOD)%MOD*c1%MOD)%MOD;
                    long long ol = p1/l;
                    int c2 = ((n/ol)%MOD - ((one*p1*p1*p1 - 1)/ol)%MOD + MOD)%MOD;
                    res = (res + 1ll*(qs_phi(ol) - qs_phi(ol - 1) + MOD)%MOD*c2%MOD)%MOD;
                }
            }
        }
    }
    cout<<res<<'\n';
}
